package gourp7_吴琪;
import java.io

        .*;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test {
    public static void main(String[] args) {
        Map<String,Integer> map=new HashMap<>();
        //字符流读文件
        BufferedReader reader=null;
        try {
            reader=new BufferedReader(new FileReader("D:\\data\\key.txt"));
            String stuNo=null;
            while ((stuNo=reader.readLine()) !=null){
                map.put(stuNo,0);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
//得到某个文件夹下面的所有文件
        File file=new File("D:\\data\\16信本2班Java作业一");
        File[] files=file.listFiles();
        //遍历
        for(File f:files){
            String fileName= f.getName();
            String no=null;
            Matcher matcher= Pattern.compile("信本2班(\\d+)").matcher(fileName);
            while (matcher.find()){
                no=matcher.group(1);
            }
            map.put(no,1);
        }
//打印所有value为0
        for (Map.Entry<String,Integer> entry:map.entrySet()){
            if (entry.getValue()==0){
                System.out.println(entry.getKey());
            }
        }
    }
}

package day20171221;
        import java.util.regex.Matcher;
        import java.util.regex.Pattern;
public class Test03 {
    public static void main(String[] args) {
//正则表达式
//面向对象程序设计Java2016级信本2班1606101025张三业1.docx
        Matcher matcher= Pattern.compile("Java(\\d+)级信本2班(\\d+)张三")
                .matcher("面向对象程序设计Java2016级信本2班1606101025张三作业1.docx");
        while (matcher.find()){
            System.out.println(matcher.group(1));
            System.out.println(matcher.group(2));
        }
    }
}